# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  https://gitee.com/autumner/pythoncookbook
@software: PyCharm 
@file: net_requests_upload.py 
@time: 2019/7/10 下午4:25
"""
'''
利用requests实现文件上传
'''
import requests

# 设置URL
url = 'http://httpbin.org/post'

# 设置上传文件
files = {'file': ('data.csv', open('data.csv', 'rb'))}

# 上传文件
r = requests.post(url, files=files)

resp=requests.get('http://httpbin.org/get',{'file':'data.csv'})
print(resp.status_code)
print(resp.text)